package com.tmall.tmall.controller;

import com.tmall.tmall.pojo.Comment;
import com.tmall.tmall.pojo.CommentRt;
import com.tmall.tmall.pojo.PageRt;
import com.tmall.tmall.pojo.Result;
import com.tmall.tmall.service.ProductOrderEvaluateService;
import com.tmall.tmall.utils.ThreadLocalUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/productOrderEvaluate")
public class ProductOrderEvaluateController {
    @Autowired
    private ProductOrderEvaluateService productOrderEvaluateService;
    @PostMapping("/add")
    public Result add(@RequestBody Comment comment){
        productOrderEvaluateService.save(comment);
        return Result.success();
    }
    @GetMapping("/page")
    public Result page(@RequestParam(defaultValue = "1") Integer pageNum,
                       @RequestParam(defaultValue = "10") Integer pageSize,
                       String username,String productName,String content,Integer productId){
        PageRt list = productOrderEvaluateService.page(pageNum,pageSize,username,productName,content,productId);
        return Result.success(list);
    }
    @PutMapping("/update")
    public Result update(@RequestBody Comment comment){
        productOrderEvaluateService.update(comment);
        return Result.success();
    }
    @DeleteMapping("/delBatch")
    public Result delete(@RequestBody List<Integer> ids){
        productOrderEvaluateService.delete(ids);
        return Result.success();
    }
}
